<?php
/// $Id: mod_random_flash.php, v1.0 June 2007 DART Creations Exp $
/**
* Joomla 1.5 Random Flash Image
* @ package Joomla
* @ joomla Open Source is Free Software
* @ Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html
* @ Author : DART Creations
* @ version $Revision: 1.0 $
**/

defined( '_JEXEC' ) or die( 'Go Away' );

//$flashfiles	= intval($params->get( 'flashfiles' ));
$flashbase = $params->get( 'flashbase' );
$quality   = $params->get( 'quality');
$background = $params->get( 'background');
$width 			= $params->get( 'width' );
$height 		= $params->get( 'height' );
$link 		= $params->get( 'link','' );

// $top = rand (1,$flashfiles);


//------------
$count = 0;
if ($handle = opendir($flashbase)) {
   $retval = array();
   while (false !== ($file = readdir($handle))) 
   {
       if (($file <> ".") && ($file <>  "..") && (strtolower(substr($file,-4)) == ".swf")) 
       {
	       $retval[$count] = $file;
	       $count = $count + 1;
       }
   }
   closedir($handle);
}
shuffle($retval);
$current_image = $retval[0];
//------------



$content = <<<EOD

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
  codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"
  width="$width" height="$height" id="g1">
 <param name="movie" value="$flashbase/$current_image"/>
 <param name="loop" value="true"/>
 <param name="quality" value="$quality"/>
 <param name="bgcolor" value="$background"/>
 <embed type="application/x-shockwave-flash" width="$width" height="$height" src="$flashbase/$current_image"></embed>
</object>
EOD;
if ($link)
	{
		$content .= "<a href=\"http://www.dart-creations.com\" style=\"font-size:1px;display:none;\">Joomla Random Flash Module by DART Creations</a>";
	}
return $content;
?>